package collectionday02exercise;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class LambdaDemo {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("one");
        list.add("two");
        list.add("three");
        list.add("four");
        list.add("five");
        list.add("one");
        System.out.println("list:"+list);//
        Collections.sort(list, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return o1.length() - o2.length();
            }
        });
        System.out.println("list:"+list);
        System.out.println("------------");
        List<String> list1 = new ArrayList<>();
        list1.add("人");
        list1.add("人们的");
        list1.add("th");
        list1.add("four");
        list1.add("fiv手手打大第三方打e");
        list1.add("为都是one");
        System.out.println("list1:"+list1);//

        list1.sort((o1,o2)->o2.length()-o1.length());
        System.out.println("list1:"+list1);
        System.out.println("------------");

    }
}
